﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace PriceCuttingWar
{
    public partial class UICard : UserControl
    {
        public UICard()
		{
			// 为初始化变量所必需
			InitializeComponent();
            FoodImage.ANI_Def.Begin();
            _FoodInfo.Type = 1;
            _FoodInfo.Money = 100;
            _FoodInfo.Money2 = 50;
            this.CacheMode = new BitmapCache();
		}
        private ItemInfo _FoodInfo;
        public ItemInfo FoodInfo
        {
            get { return _FoodInfo; }
            set
            {
                
                _FoodInfo = value;
                FoodImage.Type = value.Type;
                FoodImage.Money = value.Money;
                FoodImage.Money2 = value.Money2;
                switch (GSystem.GameMode)
                {
                    case EmGameMode.Money:
                        Money1.Text = value.Money.ToString();
                        Money2.Text = value.Money2.ToString();
                        break;
                    case EmGameMode.Cutting:
                        {
                            Money1.Text = value.Money.ToString();
                            double p = ((double)value.Money2) / ((double)value.Money);
                            int c = Convert.ToInt32(p * 10);
                            Money2.Text = (c*10) + "%";
                        }
                        break;
                    case EmGameMode.And:
                        if (GSystem.GamesRandom.Next() % 2 == 1)
                        {
                            Money1.Text = value.Money.ToString();
                            Money2.Text = value.Money2.ToString();
                        }
                        else
                        {
                            Money1.Text = value.Money.ToString();
                            double p = ((double)value.Money2) / ((double)value.Money);
                            int c = Convert.ToInt32(p * 10);
                            Money2.Text = c + "0%";
                        }
                        break;
                }                
            }
        }
    }
}
